package com.glela.controller;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.glela.platform.constant.ErrorEnum;
import com.glela.platform.model.CirculationPicture;
import com.glela.platform.model.request.SystemResponse;
import com.glela.platform.model.response.ResponseBaseModel;
import com.glela.platform.model.response.ResponseResultModel;
import com.glela.platform.service.CirculationPictureService;

@Controller
@RequestMapping(value = "/circulationPicture")
public class CirculationPictureController {

	private static Logger logger = LoggerFactory.getLogger(CirculationPictureController.class);
	@Autowired
	private CirculationPictureService circulationPictureService;
	
	/**
	 * 首页轮播图
	 * 
	 * @param requestUserSet
	 * @return
	 */
	@RequestMapping(value = "/selectCirculationPicture", method = RequestMethod.POST, consumes = "application/json")
	public ResponseEntity<?> selectCirculationPicture(SystemResponse systemResponse) {
		try {
			List<CirculationPicture> circulationPicture = circulationPictureService.selectCirculationPicture(systemResponse.getIsTop());
			return new ResponseEntity<>(new ResponseResultModel<List<CirculationPicture>>(circulationPicture), HttpStatus.OK);
		} catch (Exception e) {
			logger.error("首页轮播图:", e);
			return new ResponseEntity<>(new ResponseBaseModel(ErrorEnum.C20000), HttpStatus.OK);
		}
	}
	
	/**
	 * 首页轮播图
	 * 
	 * @param requestUserSet
	 * @return
	 */
	@RequestMapping(value = "/selectCirculationPictureNew", method = RequestMethod.POST, consumes = "application/json")
	public ResponseEntity<?> selectCirculationPictureNew(@RequestBody SystemResponse systemResponse) {
		try {
			List<CirculationPicture> circulationPicture = circulationPictureService.selectCirculationPicture(systemResponse.getIsTop());
			return new ResponseEntity<>(new ResponseResultModel<List<CirculationPicture>>(circulationPicture), HttpStatus.OK);
		} catch (Exception e) {
			logger.error("首页轮播图:", e);
			return new ResponseEntity<>(new ResponseBaseModel(ErrorEnum.C20000), HttpStatus.OK);
		}
	}
}
